package com.ukao.cashregister.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.cashregister.R;
import com.ukao.cashregister.bean.BatchlistBean;
import com.ukao.cashregister.bean.ClothIngManageBean;
import com.ukao.cashregister.utils.CheckUtils;
import com.ukao.cashregister.utils.ImageUtils;
import com.ukao.cashregister.utils.MyDateUtils;

import java.util.List;

import static com.ukao.cashregister.R.id.count;
import static com.ukao.cashregister.R.id.money;
import static com.ukao.cashregister.R.id.productName;
import static com.ukao.cashregister.R.id.selectCheckbox;
import static com.ukao.cashregister.R.id.serve;
import static com.ukao.cashregister.R.id.sortingText;
import static com.ukao.cashregister.R.id.state;

/**
 * Created by ukaodev on 2017/6/14.
 */

public class OrderClothingAdapter extends CommonAdapter<ClothIngManageBean.ListBean> {



    public OrderClothingAdapter(Context context, List<ClothIngManageBean.ListBean> item) {
        super(context, item, R.layout.adapter_order_clothing);
    }


    @Override
    public void convert(ViewHolder holder, ClothIngManageBean.ListBean item) {


        ImageView   selectCheckbox=(ImageView) holder.itemView.findViewById(R.id.select_checkbox);
        TextView   count=holder.getView(R.id.count);
        TextView   inBatch=holder.getView(R.id.inBatch);
        TextView   batchInCode=holder.getView(R.id.batchInCode);
        TextView   clothingBarcode=(TextView) holder.itemView.findViewById(R.id.clothing_barcode);
        TextView   productName=holder.getView(R.id.productName);
        productName.setText(item.getProductName());
        batchInCode.setText(CheckUtils.isEmptyString(item.getBatchInCode()));
        clothingBarcode.setText(item.getScanCode());
        if (item.getInBatch()){
            inBatch.setText("已入袋");
        }else{
            inBatch.setText("");
        }
        int  counts=getPosition(holder)+1;
        count.setText(counts+"/"+getDatas().size());
        selectCheckbox.setVisibility(item.getInBatch()? View.INVISIBLE:View.VISIBLE);
        if(item.isCheck()){
            Drawable drawable= mContext.getResources().getDrawable(R.drawable.check_box_check);
            selectCheckbox.setImageDrawable(drawable);
            holder.itemView.setBackgroundResource(R.color.back_blue);
        }else{
            Drawable drawable=  mContext.getResources().getDrawable(R.drawable.check_box_normal);
            /// 这一步必须要做,否则不会显示.
            selectCheckbox.setImageDrawable(drawable);
            holder.itemView.setBackgroundResource(R.color.white);
        }








    }








}
